package wrs.hcs.tc;

import org.openqa.selenium.WebDriver;
import wrs.hcs.functions.*;

public class WebApp_SinglePIN {

	public static WebDriver driver;
	public static String lName;
	public static String pin;
	
	static
	Webdriver d = new Webdriver();
	Login log = new Login();
	Logout out = new Logout();
	WebApp_Single s = new WebApp_Single();
	Hcs_NewPatient newPatient = new Hcs_NewPatient();
	AdminConsole_Single console = new AdminConsole_Single();
	Hcs_Nursing pack = new Hcs_Nursing();
	Hcs_Billing bill = new Hcs_Billing();
	
	public void transact() throws Exception
	{
		driver = d.startUp();
			
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login
		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		s.wellness(driver, lName, pin, false, "basic"); 						//create wrs transaction in webapp for patient
		
		driver = d.startUp();
		log.admin(driver); 														//login
		console.admin(driver, pin, "inpatient");   								//update on admin and forward to hcs
		out.admin(driver);
		
		log.hcs(driver, "nursing");
		pack.validate(driver, pin); 											//validate package of patient
		pack.discharge(driver, pin); 											//fill up discharge instructions
		pack.pf(driver, pin); 													//assign pf and discharge
		out.hcs(driver);
		log.hcs(driver, "billing"); 											//das discharge
		bill.das(driver, pin); 
		out.hcs(driver);
		log.hcs(driver, "nursing"); 											//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);
	}
	
	public void senior() throws Exception
	{
		driver = d.startUp();
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login
		String getIt = newPatient.createPatient(driver, "senior");				//new patient in hcs
		out.hcs(driver); 	
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		s.wellness(driver, lName, pin, false, "golden"); 									//create wrs transaction in webapp for patient
				
		driver = d.startUp();
		log.admin(driver); 														//login
		console.admin(driver, pin, "inpatient");   								//update on admin and forward to hcs
		out.admin(driver);
		
		log.hcs(driver, "nursing");
		pack.validate(driver, pin); 											//validate package of patient
		pack.discharge(driver, pin); 											//fill up discharge instructions
		pack.pf(driver, pin); 													//assign pf and discharge
		out.hcs(driver);
		log.hcs(driver, "billing"); 											//das discharge
		bill.das(driver, pin); 
		out.hcs(driver);
		log.hcs(driver, "nursing"); 											//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);
	}

	public void cancelReactivate() throws Exception{
		
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login
		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		s.wellness(driver, lName, pin, false, "basic"); 						//create wrs transaction in webapp for patient
		
		driver = d.startUp();
		log.admin(driver); 	
		console.cancelReactivate(driver, pin);   								//update on admin and forward to hcs
		out.admin(driver);
		
		driver.close();
		
	}
}
